#pragma once

#include <memory.h>

struct tga_image_info
{
	unsigned int dwWidth;
	unsigned int dwHeight;
	unsigned int dwColorNum;
	unsigned int dwByteNum;
	unsigned int dwPitch;
	unsigned int dwDecompression;
	unsigned int dwOrgDataSize;
	unsigned int dwColorMapType;
	unsigned int dwColorMapEntrySize;
	unsigned int dwColorMapLength;
};


#pragma pack(1)
struct TGAHeader
{
	unsigned char IdLength;
	unsigned char ColorMapType;
	unsigned char ImageType;
	unsigned char FirstEntryIndex[2];
	unsigned short ColorMapLength;
	unsigned char ColorMapEntrySize;
	unsigned char XOrigin[2];
	unsigned char YOrigin[2];
	unsigned short ImageWidth;
	unsigned short ImageHeight;
	unsigned char PixelDepth;
	unsigned char ImageDescriptor;
};

struct TGATailer{
	unsigned int ExtensionOffset;
	unsigned int DeveloperOffset;
	unsigned char  Signature[18];
};




void set_tga_data(unsigned char * pData);
void read_tga_data(void * pDst,unsigned int size);
void read_tga_header( TGAHeader * pHeader);
void read_tga_image(unsigned char ** ppOut, tga_image_info * pInfo);